<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>用户列表</title>
  <script src="/js/jquery-3.4.1/jquery-3.4.1.js"></script>
</head>
<body>
<h1>用户列表</h1>
<hr>
<a href="/add">添加</a>
<table th:border="1">
  <tbody>
  <tr>
    <th>编号</th>
    <th>用户名</th>
    <th>密码</th>
    <th>姓名</th>
    <th>年龄</th>
    <th>性别</th>
    <th>生日</th>
    <th>备注</th>
    <th>操作</th>
  </tr>
  <tr th:each="user : ${list}">
    <td th:text="${user.id}">1</td>
    <td th:text="${user.username}">zhangsan</td>
    <td th:text="${user.password}">123444</td>
    <td th:text="${user.name}">张三</td>
    <td th:text="${user.age}">20</td>
    <td th:text="${user.sex} == 1 ? '男': '女'">男</td>
    <td th:text="${#dates.format(user.birthday, 'yyyy-MM-dd')}">1980-02-30</td>
    <td th:text="${user.note}">1</td>
    <td>
      <a th:attr="del_url=@{/user/}+${user.id}" class="del_user btn btn-danger btn-sm">删除</a>
      <a th:href="@{/user/}+${user.id}" class="btn btn-info btn-sm">修改</a>
    </td>
  </tr>
  </tbody>
</table>
<form id="del_form" method="post">
<input type="hidden" name="_method" th:value="delete">
</form>
<script>
  $(".del_user").click(function (){
    $("#del_form").after("action",$(this).after('del_url')).submit();
  })

</script>
</body>